package com.edushare.common.vo;

import java.util.Date;

import com.edushare.common.vo.auto._GradingItem;

public class GradingItem extends _GradingItem implements DateComparision {
	public static final int ITEM_EXAM = 10;
	public static final int ITEM_ATTENDANCE = 20;
	public static final int ITEM_COURSE_TEST = 30;
	public static final int ITEM_COURSE_ASSGN = 40;
	public static final int ITEM_OTHERS = 50;

	public static final int GRADE_LETTER = 10;
	public static final int GRADE_MARKS = 20;

	public GradingItem() {
		setCreationDate(new Date());
	}

	public String getItemTypeString() {
		switch (getItemType()) {
		case ITEM_EXAM:
			return "Examination";
		case ITEM_ATTENDANCE:
			return "Attendance";
		case ITEM_COURSE_TEST:
			return "Quiz";
		case ITEM_COURSE_ASSGN:
			return "Assignment";
		case ITEM_OTHERS:
			return "Others";
		}
		return "";
	}

	public String getGradingTypeString() {
		if (getGradeType() == GRADE_LETTER)
			return "Grades";
		return "Marks";
	}

	public int compareTo(IDateComparable arg0) {
		if(getDate().getTime() < arg0.getDate().getTime())
			return -1;
		else if(arg0.getDate().getTime() == getDate().getTime())
			return 0;
		else
			return 1;
	}

	public Date getDate() {
		return getCreationDate();
	}
	
	@Override
	public String getGradingItemName(){
		if(getItemType() == GradingItem.ITEM_COURSE_ASSGN){
			return getAssignment().getAssignmentTitle();
		}
		return super.getGradingItemName();
	}
	
	@Override
	public String getGradingItemDesc(){
		if(getItemType() == GradingItem.ITEM_COURSE_ASSGN){
			return getAssignment().getAssignmentDesc();
		}
		return super.getGradingItemDesc();
	}
}
